const mongoose = require("mongoose");
var Stomp = require("stomp-client");
var Food = mongoose.model("food");
var destination = '/queue/ita_p4_pic_mq';
var client = new Stomp('10.222.232.152', 61613, '', '');

client.connect(function (sessionId) {
//???
    client.subscribe(destination, function (body, headers) {
        console.log('regist Merchant m2a jms : merchant json');
        console.log("Headers:" + headers);
        console.log("Body:" + body);
        var obj = JSON.parse(body)
        var food = new Food(obj);
        food.save(function (err) {
            console.log("ps:food.save");
        });
    });
//???
// client.publisher(destination,'john');
});